#include "GY_FloatData.h"

GY_FloatData::GY_FloatData(const QString &guid, QGraphicsItem *parent)
    :GY_BasicsDataObjects(guid,this,parent)
{
    //图元类型
    GY_Object::setUserData(GY_ENUM::ClassType,QVariant("FloatData"));
    initializationPropertyInfo();
}

void GY_FloatData::initializationPropertyInfo()
{
    GY_PropertyInfo ObjectName(this);
    ObjectName.propertyName = "ObjectName";
    ObjectName.propertyValue = QString();
    ObjectName.updateType = Update;
    ObjectName.propertyType = QStringPropertyType;
    ObjectName.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_FloatData::updateObjectName;
    m_PropertyInfoMap.insert(ObjectName.propertyName,ObjectName);
    m_PropertyInfoMap[ObjectName.propertyName].setConnect();

    GY_PropertyInfo Value(this);
    Value.propertyName = "Value";
    Value.propertyValue = float(0);
    Value.updateType = Update;
    Value.propertyType = FloatPropertyType;
    Value.updatePropertyFun = (GY_PropertyInfo::UpdatePropertyFun)&GY_FloatData::updateValue;
    m_PropertyInfoMap.insert(Value.propertyName,Value);
    m_PropertyInfoMap[Value.propertyName].setConnect();
}

bool GY_FloatData::updateValue(const QString &name, const QVariant &value)
{
    if(!value.canConvert<float>()) {
        return false;
    }
    m_PropertyInfoMap[name].propertyValue = value;
    return true;
}
